/**
 * Copyright (C) 2025 pony working team
 * SPDX-License-Identifier: MulanPSL-2.0
 */

/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __PONY_IAPER_H__
#define __PONY_IAPER_H__

/* includes (standard library, system) ---------------------------------------*/
#include <stdint.h>
#include <stddef.h>
/* includes (other library) --------------------------------------------------*/
/* includes (project) --------------------------------------------------------*/
/* includes (local) ----------------------------------------------------------*/

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* defines -------------------------------------------------------------------*/
/* typedefs ------------------------------------------------------------------*/

enum iaper_lpar_id {
    IAP_LPAR_ID_LOADER,
    IAP_LPAR_ID_APP,
};

// iaper is IAP Bootloader
typedef struct iaper {
    size_t (*filesize)(uintptr_t);
    const char *(*filename)(uintptr_t);
    int (*downloader)(uintptr_t);
    unsigned char (*getc)(uintptr_t, size_t timeout);
    int (*putc)(uintptr_t, unsigned char);
    uintptr_t arg;
} iaper_t;

/* macro ---------------------------------------------------------------------*/
/* inlines -------------------------------------------------------------------*/
/* externs -------------------------------------------------------------------*/

extern int iaper_loop(uintptr_t arg);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __PONY_IAPER_H__ */
